#!/usr/bin/python
# -*- coding: cp1250 -*-

import psycopg2
  
class DB:
    ''' '''
    def __init__(self):
        ''' '''
        pass

    def getCur(self, con):
        #try:
        if con == '':
            self.con = psycopg2.connect("dbname='work' user='postgres' host='127.0.0.1' password=''") # create connection
        else:
            self.con = psycopg2.connect(con) # create connection
        #except:
        #    print "I am unable to connect to the database"
        self.cur = self.con.cursor()

    def exeQry(self, q):
        self.cur.execute(q)
        return self.cur.fetchall() # cur.fetchall() or cur.fetchone()

if __name__ == "__main__":
    ''' '''
    x = DB()
    x.getCur("dbname='work' user='postgres' host='127.0.0.1' password=''")
    q = """select * from t002fileb where c001 in ('0000000002', '0020000000','0010045000','0010405000')"""
    for row in x.exeQry(q):
        print row[0], row[1]
    q = """select * from t002fileb where c001 in ('0000001002', '0010001000','0010045100','0010405100')"""
    for row in x.exeQry(q):
        print row[0], row[1]







